<?php

namespace App\Services\Account;

use Illuminate\Database\Eloquent\Relations\HasMany;

class AccountGoldBeans extends AccountAbstract
{
    protected function account(): HasMany
    {
        return $this->user->goldBeans();
    }

    /*---------- plus --------------------------------------------------------------------------------------------------*/

	public function plusOrderBeans($beans, $data = [])
	{
		$beans = big_decimal($beans);
		$this->record($beans, 'order_gold_beans', '平台赠送', $data);
	}

	public function plusTransferedBeans($beans, $data = [])
	{
		$beans = big_decimal($beans);
		$this->record($beans, 'transfered_in_beans', '转入金豆', $data);
	}

	public function plusSupportedGoldBeans($beans, $data = [])
	{
		$beans = big_decimal($beans);
		$this->record($beans, 'support_gold_beans', '平台扶持金豆', $data);
	}

	public function plusPresentGoldBeans($beans, $data = [])
	{
		$beans = big_decimal($beans);
		$this->record($beans, 'present_gold_beans', '平台充值金豆', $data);
	}

	public function plusExtraGoldBeans($beans, $data = [])
	{
		$beans = big_decimal($beans);
		$this->record($beans, 'extra_gold_beans_return', '抢购异常金豆回退', $data);
	}


	public function plusEachGoldBeans($beans, $data = [])
	{
		$beans = big_decimal($beans);
		$this->record($beans, 'charge_gold_beans', '金豆充值', $data);
	}


	/*---------- minus -------------------------------------------------------------------------------------------------*/

	public function minusTransferedBeans($beans, $data = [])
	{
		$beans = big_decimal($beans)->multipliedBy(-1);
		$this->record($beans, 'transfered_out_beans', '转出金豆', $data);
	}

	public function minusOvertimeFineBeans($beans, $data = [])
	{
        $beans = big_decimal($beans)->multipliedBy(-1);
        $this->record($beans, 'overtime_fine_beans', '超时未支付处罚', $data);
	}

	public function minusFromBuyingCashes($beans, $data = [])
	{
        $beans = big_decimal($beans)->multipliedBy(-1);
        $this->record($beans, 'buying_gold_cashes', '兑换抢购金', $data);
	}

	public function minusResellFeeBeans($beans, $data = [])
	{
		$beans = big_decimal($beans)->multipliedBy(-1);
		$this->record($beans, 'reselling_fee_beans', '寄卖消耗金豆', $data);
	}

	public function minusSeckillBeans($beans, $data = [])
	{
		$beans = big_decimal($beans)->multipliedBy(-1);
		$this->record($beans, 'reselling_fee_beans', '抢购消耗金豆', $data);
	}

	public function minusSplitFeeBeans($beans, $data = [])
	{
		$beans = big_decimal($beans)->multipliedBy(-1);
		$this->record($beans, 'split_fee_beans', '申请置换补贴消耗金豆', $data);
	}

	public function minusSystemRecall($beans, $data = [])
	{
		$beans = big_decimal($beans)->multipliedBy(-1);
		$this->record($beans, 'system_recall', '系统回收', $data);
	}


	public function minusOrderPaid($coins, $data = [])
	{
		$money = big_decimal($coins)->multipliedBy(-1);
		$this->record($money, 'pay_order', '积分商品订单支出', $data);
	}
}
